<html>
	<head>
		<meta charset="utf-8"/>
	</head>
	<body>
	<?php 
		$daction = $_SESSION['action'];
		include 'operations/connection.php';		
		$query = mysql_query("select a.Tile,a.Content,a.Content2,e.Fullname,a.Timecreate,a.Description,a.IDGroupApprove,a.IDStatus from approvedoc a 
				inner join employee e on a.IDEmployee = e.IDEmployee where a.IDApproveDoc = '$id'");
		while ($row = mysql_fetch_array($query))
		{
			$dtitle = $row[Tile];
			$dcontent = $row[Content];
			$dcontent2 = $row[Content2];
			$dtime = $row[Timecreate];
			$duser = $row[Fullname];
			$ddescription = $row[Description];
			$didgroupapprover = $row[IDGroupApprove];
			$dstatus = $row[IDStatus];
		}
	?>
	<div class="main_content">
           <ul class="top_but">
				<li><a  class="back-button"><img src="images/back.png" alt="" /></a><p class="hidden">Back</p></li>
				<?php if($daction=="re_not_approve"){?>
				<li><a href="<?echo approve($didgroupapprover, $id_employee)?>"><img src="images/approval.png" alt="" /></a><p class="hidden">Approve</p></li>
				<li><a href="<?echo reject($didgroupapprover, $id_employee)?>"><img src="images/reject.png" alt="" /></a><p class="hidden">Reject</p></li>
				<?php }?>
				<?php
					if($daction == "re_reference_waiting"){
				?>
					<li><a href="<?echo viewReference($didgroupapprover, $id_employee)?>"><img src="images/approval.png" alt="" /></a><p class="hidden">Accept</p></li>
				<?php }?>
			</ul>
            <table class="tcontent" cellpadding="5" cellspacing="0">  
            	<tr>
            	<td class="col_left" width="15%"><?=$l_approver?></td>
                    <td>
                    	<table style="width: 100%;" cellpadding="5" cellspacing="0">
                    		<tr>
                    			<td><?=$l_step?></td>
                    			<td>
                    				<?
                    				//Get group approver
                    				$query1 = mysql_query("SELECT l.IDStatus,l.DateApprove,e.Fullname FROM listapprove l
                    						INNER JOIN employee e ON l.IDEmployee = e.IDEmployee
                    						WHERE CONVERT(l.IDGroupApprove USING utf8) = CONVERT('$didgroupapprover' USING utf8)
                    						ORDER BY l.Order ASC");
                    				while ($row = mysql_fetch_array($query1))
                    				{
                    					$dnameapprover = $row[Fullname];
                    					$ddateapproved = $row[DateApprove];
                    					if ($row[IDStatus] == 1){
                    						$dstatus="";
                    					}
                    				?>
                    				<span style="display: block;">
                    					<b><?=$dnameapprover?></b>_<?=$dstatus?>_<?=$ddateapproved?>
                    				</span>
                    				<?
                    				}
                    				?>
                    			</td>
                    			<td>
                    				<?
                    				//Get list references
                    				$query2 = mysql_query("SELECT e.Fullname FROM list_reference l
                    						INNER JOIN employee e ON l.id_employee = e.IDEmployee
                    						WHERE CONVERT(l.id_group USING utf8) = CONVERT('$didgroupapprover' USING utf8)");
                    				while ($row = mysql_fetch_array($query2))
                    				{
                    					$dnamereferences = $row[Fullname];
                    				?>
                    				<b><?=$dnamereferences?></b>;
                    				<?
                    				}
                    				?>
                    			</td>
                    		</tr>
                    	</table>
                    </td>
            	</tr>             
                <tr>
                	<td width="15%" class="col_left"><?=$l_title?></td>
                    <td><?=$dtitle?></td>
                </tr>
                <tr>
                	<td class="col_left"><?=$l_description?></td>
                    <td><?=$ddescription?></td>
                </tr>                                      
            </table>
            <br />
            <table class="tcontent" cellpadding="5" cellspacing="0">               
                <tr>
                	<td style="text-align:left" colspan="2"><b><?=$l_writer?></b> Lê Xuân Huy</td>
                </tr>
                <tr>
                	<td style="text-align:left"><?=$dcontent?></td>
                    <td style="text-align:left"><?=$dcontent2?></td>
                </tr>                                                    
            </table>
      </div>
	</body>
    <?php mysql_close($connection);?>
</html>